package cn.etg.day06;

import java.io.Serializable;

/**
 * 定义私有属性:
 * String name;
 * int age;
 * String gender;
 * int salary;

 * 
 * 定义构造方法，以及属性get,set方法.
 * 定义toString方法，格式如:
 *    姓名:张三,年龄:25,性别:男,薪资:5000 
 * 定义equals方法，要求只要名字相同，则认为内容一致。
 * @author Xiloer
 *
 */
public class Emp implements Serializable {
    private static final long serialVersionUID = -3766125171806977957L;
    private String name;
    private int age;
    private String gender;
    private int salary;

    public Emp(String name, int age, String gender, int salary) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return name + "," + age + "," + gender + "," + salary;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Emp emp = (Emp) o;
        return name.equals(emp.name);
    }
}
